home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1994 December
/
PSL Monthly Shareware CD-ROM (Public Software Library)(December 1994).bin
/
prgmming
/
dos
/
asm
/
load.asm
< prev
next >
Wrap
Assembly Source File
|
1984-03-04
|
3KB
|
121 lines
NAME LOAD
PAGE 55,128
TITLE 'LOAD -- LOAD .COM FILE FOR MS-DOS 2.0'
;
;
; LOAD -- LOAD .COM FILE BIGGER THAN 64K
; REQUIRES MS-DOS 2.0
; VERSION 1.1 DEC 83 RGD
; VERSION 1 MARCH 1983 RJW
; COPYRIGHT (C) 1983
; LABORATORY MICROSYSTEMS
; 4147 BEETHOVEN STREET
; LOS ANGELES, CA 90066
;
CR EQU 0DH ;ASCII CARRIAGE RETURN
LF EQU 0AH ;ASCII LINE FEED
CSEG SEGMENT BYTE
ORG 100H
ASSUME CS:CSEG,DS:CSEG
LOAD PROC FAR ; SETS UP FAR RETURN ...
PUSH ES ; SAVE SEGMENT OF PSP
MOV DX,OFFSET MES2 ; STARTUP MESSAGE
MOV AH,9
INT 21H
XOR DX,DX ; ZERO DX
MOV AH,25H ; SET TERMINATE ADDRESS ...
MOV AL,22H ; ... FOR NEW PROGRAM SEGMENT
INT 21H
MOV DX,OFFSET ENDOFS ; OFFSET TO END OF THIS LOADER
MOV CL,4 ; NO OF BITS TO SHIFT
SHR DX,CL ; CONVERT BYTE ADDR TO PARAGRAPH
INC DX ; OFFSET OF 1ST AVAILABLE SEGMENT
MOV AX,CS ; CURRENT SEGMENT TO AX
ADD DX,AX ; ACTUAL VALUE OF 1ST AVAILABLE SEGMENT
MOV USEG,DX ; SAVE IT FOR LATER ...
MOV ES,DX ; ... AND FOR SUBSEQUENT MOVE
MOV AH,26H ; CALL TO DOS
INT 21H ; CREATE NEW PROGRAM SEGMENT
MOV SI,6CH ; 2ND PARAM FCB IN CURRENT SEGMENT
MOV DI,5CH ; 1ST PARAM FCB IN NEW SEGMENT
MOV CX,0CH ; BYTE COUNT FOR MOVE
REPZ MOVSB ; COPY THE FILENAME
MOV AX,CS ; COPY CURRENT CODE SEG ...
MOV DS,AX ; ... TO DS
MOV DX,5CH ; DS:DX POINTS TO FCB OF .COM FILE
MOV BX,DX ; MAKE FCB ADDRESSIBLE
MOV BYTE PTR 9 [BX],'C' ; FORCE COM EXTENSION
MOV BYTE PTR 10 [BX],'O'
MOV BYTE PTR 11 [BX],'M'
MOV AH,0FH ; OPEN THE .COM FILE
INT 21H
OR AL,AL ; TEST RETURN CODE
JNZ LOAD8 ; EXIT IF NON-ZERO
MOV WORD PTR 33 [BX],0000 ; ZERO THE RANDOM
MOV WORD PTR 35 [BX],0000 ; RECORD FIELD IN THE FCB
POP ES ; GET LOADER'S PSP SEGMENT
MOV BX,USEG ; LET SS:SP = DEFAULT BUFFER OF
MOV SS,BX ; NEW PSP
MOV SP,100H
PUSH ES ; SAVE LOADER'S PSP AGAIN
ADD BX,10H ; BX = SEGMENT OF CURRENT DTA
MOV DS,BX ; SET UP DS:DX TO POINT TO THE DTA
XOR DX,DX
MOV AH,1AH ; SET UP DOS CALL AND DO IT
INT 21H
LOAD5: MOV CX,100H ; NUMBER OF RECORDS OF LENGTH 80H
MOV AX,CS ; COPY CURRENT CS TO DS
MOV DS,AX
MOV DX,5CH ; DS:DH POINTS TO FCB OF .COM FILE
MOV AH,27H ; DO RANDOM BLOCK READ
INT 21H
TEST AL,1 ; END OF FILE?
JNZ LOAD9 ; YES, SO EXIT
ADD BX,800H ; INCREMENT LOCATION OF DTA
MOV DS,BX ; COPY TO DS
XOR DX,DX ; DS:DX NOW POINTS TO NEXT DTA
MOV AH,1AH ; SET UP DOS CALL TO SET DTA
INT 21H
JMP LOAD5 ; DO IT AGAIN
LOAD8: MOV DX,OFFSET MES1 ; "FILE NOT FOUND"
MOV AH,9 ; WRITE TO TERMINAL
INT 21H
INT 20H ; EXIT TO DOS
LOAD9: MOV AX,USEG ; SET UP REGISTERS FOR NEW SEGMENT
MOV DS,AX
POP ES ; PASS LOADER'S PSP SEGMENT TO OVERLAY
PUSH AX ; PUSH NEW CS ONTO STACK
MOV AX,100H
PUSH AX ; PUSH OFFSET ONTO STACK
RET ; FAR RETURN CAUSES CS:IP TO BE SET
LOAD ENDP
MES1 DB CR,LF,
DB '.COM FILE NOT FOUND'
DB CR,LF,'$'
MES2 DB CR,LF
DB 'MULTI-SEGMENT LOADER VERSION 1.1 FOR MS-DOS 2.0'
DB CR,LF
DB 'COPYRIGHT (C) 1983 LABORATORY MICROSYSTEMS INC.'
DB CR,LF,'$'
USEG DW 0
ENDOFS EQU $
CSEG ENDS ; END OF CODE SEGMENT
END LOAD